package com.example.demo.serialize;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.jackson.JsonComponent;

import java.io.IOException;

/**
 * 序列化
 */
//@JsonComponent
public class JsonSerialize extends JsonSerializer<JSONObject> {
    @Override
    public void serialize(JSONObject s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        System.out.println("序列化serialize....");
        jsonGenerator.writeString(s.toString());
    }
}
